﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Data.OleDb;

namespace Capstone_project
{
    public partial class frmAddProject : Form
    {
        public frmAddProject()
        {
            InitializeComponent();
        }

        private void frmAddProject_Load(object sender, EventArgs e)
        {
            // TODO: This line of code loads data into the 'databaseDataSet4.PROJECT_STATUS' table. You can move, or remove it, as needed.
            this.pROJECT_STATUSTableAdapter.Fill(this.databaseDataSet4.PROJECT_STATUS);
            // TODO: This line of code loads data into the 'databaseDataSet3.CUSTOMER' table. You can move, or remove it, as needed.
            this.cUSTOMERTableAdapter.Fill(this.databaseDataSet3.CUSTOMER);
            // TODO: This line of code loads data into the 'databaseDataSet3.CUSTOMER' table. You can move, or remove it, as needed.
           

        }
        OleDbConnection con = new OleDbConnection(@"Provider=Microsoft.ACE.OLEDB.12.0;Data Source=C:\Users\XuanThanh\Desktop\capstoneproject-clggroup\Capstone project\Capstone project\database.accdb");
        private void btnCancel_Click(object sender, EventArgs e)
        {
            this.Close();
        }

        private void btnOK_Click(object sender, EventArgs e)
        {
            if (txtIdProject.Text == "" || txtNameProject.Text == "" || dtpStartDate.Text == "" || dtpEndDate.Text == "")
            {
                MessageBox.Show("You must enter all infomation");
            }
            else
            {
                con.Open();
                string sql = "INSERT INTO PROJECT(ID_PROJECT,NAME_PROJECT,ID_CUSTOMER,ID_STATUS,START_DATE,END_DATE,PARENT)VALUES('" + txtIdProject.Text + "','" + txtNameProject.Text + "','" + cmbCustomer.SelectedValue + "','" + cmbStatus.SelectedValue + "','" + dtpStartDate.Text + "','" + dtpEndDate.Text + "','1')";
                OleDbCommand com = new OleDbCommand(sql, con);
                com.ExecuteNonQuery();
                MessageBox.Show("Project added successfully !");
                con.Close();  
            }
        }
    }
}
